home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / softwareupdate / system / amigados / amigadoslibrary / fread.c < prev    next >
C/C++ Source or Header  |  1996-10-10  |  1KB  |  52 lines

  1. /* FRead.c   V1.2   93-03-03                   */
  2. /* ROM library: "dos.library/FRead", (V36+)    */
  3. /* Copyright 1993, Anders Bjerin, Amiga C Club */
  4.  
  5. #include <dos/dos.h>
  6.  
  7. #include <clib/dos_protos.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. #define BLOCK_SIZE 512
  12. #define NO_BLOCKS   10
  13.  
  14. UBYTE *version = "$VER: FRead 1.2";
  15.  
  16. int main( int argc, char *argv[] );
  17. int main( int argc, char *argv[] )
  18. {
  19.   UBYTE my_buffer[ NO_BLOCKS ][ BLOCK_SIZE ];
  20.   BPTR my_file;
  21.   LONG blocks_read;
  22.  
  23.  
  24.   /* Open an old file: */
  25.   my_file = Open( "RAM:Important.dat", MODE_OLDFILE );
  26.   if( !my_file )
  27.     exit( 21 );
  28.  
  29.   /* Clear the global error code: */
  30.   SetIoErr( 0 );
  31.  
  32.   /* Read some data: */
  33.   blocks_read = FRead( my_file, my_buffer, BLOCK_SIZE, NO_BLOCKS );
  34.  
  35.   /* OK? */
  36.   if( blocks_read != NO_BLOCKS )
  37.   {
  38.     /* Not all data collected! EOF or Error? */
  39.     if( IoErr() )
  40.       printf( "Error while reading!\n" );
  41.     else
  42.       printf( "End Of File!\n" );
  43.   }
  44.   else
  45.     printf( "The data was successsfully collected!\n" );
  46.  
  47.   Close( my_file );
  48.  
  49.   exit( 0 );
  50. }
  51.  
  52.